{
    class User {
        name: string = '用户';
        getName() {
            console.log('User: ', this)
        }
        getClass() {
            console.log('User')
        }
    }
    
    class Admin {
        name: string = '管理员';
        getName() {
            console.log('Admin: ', this)
        }
    }

    class SuperAdmin {
        name: string = '超级管理员';
        getName() {
            console.log('SuperAdmin: ', this.name)
        }
    }
    
    // 声明一个构造签名
    type Constructor<T = {}> = new (...args: any) => T;

    type NoReadonly<T> = {
        -readonly [K in keyof T]: T[K]
    }
    
    function applyMixins<T, H extends Constructor[]>(Base: Constructor<T>, mixins: H) {
        mixins.forEach(mixin => {
            // 只获取mixin.prototype自身的属性。并不获取class函数的自身属性
            Object.getOwnPropertyNames(mixin.prototype).forEach((name: string) => {
                if(name !== 'constructor') {
                    const descriptor = Object.getOwnPropertyDescriptor(mixin.prototype, name)!;
                    Object.defineProperty(Base.prototype, name, descriptor)
                }
            })
        })
    }
    
    const mixins = [User, Admin] as const;

    applyMixins<SuperAdmin, NoReadonly<typeof mixins>>(SuperAdmin, <NoReadonly<typeof mixins>>mixins)

    const p = new SuperAdmin();
    p.getName();
    if('getClass' in p && typeof p.getClass == 'function') {
        p.getClass()
    }
}